/* XBI */
/* xbixfselement.h */
/*
 The Xbox game data is architecture in a file system. This filesystem is stored on disk as a binary tree, the actual
 B-tree hiearchy being totally different from the actual filesystem hierarchy. However, each node in the B-tree is
 also a node in the filesystem tree (that is to say a file or a folder). The XFSElement structure represents such
 a node.
 
 On the actual disc, a bunch of XFSElement are laid out. Each element contains a couple of offsets, that points to a
 couple of other XFSElements. A node pointing to another in the B-tree is actually a sibling in terms of filesystem
 hierarchy. Some special nodes however have a 'folder' identifier, and a pointer to another B-tree, representing
 their children, filesystem-wise.
 */

#ifndef XBI_XFSElement
#define XBI_XFSElement 1

typedef struct _XBIXFSElement XBIXFSElement;

#include <xbi/xbicommon.h>
#include <xbi/xbiimage.h>

// Creation - Copy - Deletion
XBIXFSElement * XBIXFSElementCreate(XBIImage * image, XBIError * error);
XBIXFSElement * XBIXFSElementCopy(XBIXFSElement * element);
void XBIXFSElementDelete(XBIXFSElement * element);

// Data manipulation
int XBIXFSElementIsFolder(XBIXFSElement * element);
XBIXFSElement * XBIXFSElementFindChildWithPath(XBIXFSElement * element, char * path, size_t pathLength);
int XBIXFSElementCopyFullPath(XBIXFSElement * element, char * buffer, size_t bufferSize);
off_t XBIXFSElementGetStartByte(XBIXFSElement * element);
uint64_t XBIXFSElementGetSize(XBIXFSElement * element);

// Accessors
char * XBIXFSElementGetName(XBIXFSElement * element);
XBIXFSElement * XBIXFSElementGetChildrenAtIndex(XBIXFSElement * element, int index);
int XBIXFSElementGetNumberOfChildren(XBIXFSElement * element);

#endif
